package com.project.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.bean.RegionBean;
import com.project.service.RegionService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * 区域
 */
@Controller
@RequestMapping("region")
public class RegionController {


    @Resource
    private RegionService regionService;

    /**
     * 分页显示
     * @param pageNO
     * @param pageSize
     * @return
     */
    @RequestMapping("findAllRegion")
    @ResponseBody
    public IPage<RegionBean> findAllRegion(@RequestParam(value = "pageNO", defaultValue = "1") int pageNO,
                                         @RequestParam(value = "pageSize", defaultValue = "3") int pageSize) {
        return regionService.findAllRegion(pageNO, pageSize);
    }

    /**
     * 添加
     * @param regionBean
     * @return
     */
    @RequestMapping("addRegion")
    @ResponseBody
    public String addRegion(RegionBean regionBean) {
        regionService.addRegion(regionBean);
        return "添加成功";
    }


    /**
     * 区域林种小班模糊查询
     * @param pageNO
     * @param pageSize
     * @param regionName
     * @param regionForest
     * @param classList
     * @return
     */
    @RequestMapping("findName")
    @ResponseBody
    public IPage<RegionBean> findName(@RequestParam(value = "pageNO", defaultValue = "1") int pageNO,
                                    @RequestParam(value = "pageSize", defaultValue = "3") int pageSize,
                                    String regionName, String regionForest, String classList) {
        return regionService.findName(pageNO, pageSize, regionName, regionForest, classList);
    }
}
